<template>
  <div class="dashboard-container">
    <div class="app-container">
      <!-- 流程步骤展示 -->
      <div class="process-header">
        <h2>订单流程管理</h2>
        <p>当前进度：拼片（第6步/共22步）</p>
      </div>
      <div class="steps">
        <el-steps :active="6" align-center>
          <el-step v-for="(step, index) in processSteps" :key="index" :title="step" />
        </el-steps>
      </div>
      
      <!-- 订单表单 -->
      <div class="order-card">
        <div class="form-container">
          <el-form :model="formData" label-width="150px" label-position="top">
            <!-- 订单基础信息区域 -->
            <div class="form-section">
              <h3 class="section-title">订单基础信息</h3>
              <div class="form-grid">
                <div class="form-group">
                  <el-form-item label="订单编号">
                    <el-input v-model="formData.orderNumber" readonly class="form-input" />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="批发商参考号">
                    <el-input v-model="formData.wholesalersRefNo" class="form-input" />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="订单日期">
                    <el-date-picker 
                      v-model="formData.orderDate"
                      type="date" 
                      class="form-input"
                      value-format="yyyy-MM-dd"
                    />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="预计发货日期">
                    <el-date-picker 
                      v-model="formData.estimatedShippingDate"
                      type="date" 
                      class="form-input"
                      value-format="yyyy-MM-dd"
                    />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="订单类型">
                    <el-select 
                      v-model="formData.typeOfOrder" 
                      placeholder="请选择"
                      class="form-input"
                    >
                      <el-option label="Kippot" value="kippot" />
                      <el-option label="Challah Cover" value="challah" />
                      <el-option label="Bag" value="bag" />
                    </el-select>
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="事件日期 (可选)">
                    <el-date-picker 
                      v-model="formData.eventDate"
                      type="date" 
                      class="form-input"
                      value-format="yyyy-MM-dd"
                    />
                  </el-form-item>
                </div>
              </div>
            </div>
            
            <!-- 客户信息区域 -->
            <div class="form-section">
              <h3 class="section-title">客户信息</h3>
              <div class="form-grid">
                <div class="form-group">
                  <el-form-item label="客户姓名">
                    <el-input v-model="formData.fullName" class="form-input" />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="商品编号">
                    <el-input v-model="formData.itemNumber" class="form-input" />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="数量">
                    <el-input-number 
                      v-model="formData.quantity" 
                      :min="1"
                      class="form-input"
                    />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="电话">
                    <el-input v-model="formData.telephone" class="form-input" />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="尺寸">
                    <el-input v-model="formData.size" class="form-input" />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="邮箱">
                    <el-input v-model="formData.email" class="form-input" />
                  </el-form-item>
                </div>
                <div class="form-group full-width">
                  <el-form-item label="配送地址">
                    <el-input 
                      v-model="formData.shippingAddress" 
                      type="textarea" 
                      :rows="3" 
                      class="form-input"
                    />
                  </el-form-item>
                </div>
              </div>
            </div>
            
            <!-- 产品细节区域 -->
            <div class="form-section">
              <h3 class="section-title">产品细节</h3>
              <div class="color-grid">
                <div class="form-group">
                  <el-form-item label="面板数">
                    <el-input-number 
                      v-model="formData.panel" 
                      :min="1" 
                      :max="8" 
                      class="form-input"
                    />
                  </el-form-item>
                </div>
                <div class="color-item" v-for="colorField in colorFields" :key="colorField.prop">
                  <el-form-item :label="colorField.label">
                    <el-color-picker v-model="formData[colorField.prop]" />
                    <span class="color-value">{{ formData[colorField.prop] || '未设置' }}</span>
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="商家标签">
                    <el-input v-model="formData.sellersTag" class="form-input" />
                  </el-form-item>
                </div>
                <div class="form-group full-width">
                  <el-form-item label="外部刺绣/印刷">
                    <el-input 
                      v-model="formData.outsideEmbroidery" 
                      class="form-input"
                      placeholder="例如：NATHAN PETER LEVINSON STIFTUNG"
                    />
                  </el-form-item>
                </div>
                <div class="form-group full-width">
                  <el-form-item label="内部印刷/标签/刺绣">
                    <el-input 
                      v-model="formData.insidePrintings" 
                      class="form-input"
                      placeholder="例如：Logo and name"
                    />
                  </el-form-item>
                </div>
                <div class="form-group full-width">
                  <el-form-item label="特殊要求（客户）">
                    <el-input 
                      v-model="formData.specialRequest" 
                      type="textarea" 
                      :rows="3" 
                      class="form-input"
                    />
                  </el-form-item>
                </div>
              </div>
            </div>
            
            <!-- 订单状态区域 -->
            <div class="form-section">
              <h3 class="section-title">订单状态</h3>
              <div class="form-grid">
                <div class="form-group">
                  <el-form-item label="订单状态">
                    <el-select v-model="formData.orderStatus" class="form-input">
                      <el-option label="待处理" value="pending" />
                      <el-option label="生产中" value="production" />
                      <el-option label="已发货" value="shipped" />
                    </el-select>
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="实际发货日期">
                    <el-date-picker 
                      v-model="formData.shippingDate" 
                      type="date"
                      value-format="yyyy-MM-dd"
                      class="form-input"
                    />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="快递公司">
                    <el-input v-model="formData.courier" class="form-input" />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="物流单号">
                    <el-input v-model="formData.trackingNumber" class="form-input" />
                  </el-form-item>
                </div>
                <div class="form-group">
                  <el-form-item label="商品照片">
                    <div class="image-upload-container">
                      <img v-if="formData.itemPhoto" :src="formData.itemPhoto" class="item-image" alt="商品照片" />
                      <div v-else class="image-placeholder">
                        <i class="el-icon-picture-outline"></i>
                        <p>上传照片</p>
                      </div>
                    </div>
                  </el-form-item>
                </div>
                <div class="form-group full-width">
                  <el-form-item label="操作员备注">
                    <el-input 
                      v-model="formData.orderRemarks" 
                      type="textarea" 
                      :rows="3" 
                      class="form-input"
                    />
                  </el-form-item>
                </div>
              </div>
            </div>
            
            <!-- 操作按钮 -->
            <div class="action-buttons">
              <el-button type="primary" icon="el-icon-check" class="btn-save">保存更改</el-button>
              <el-button icon="el-icon-close" class="btn-cancel">取消</el-button>
            </div>
          </el-form>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'OrderDetail',
  data() {
    return {
      // 流程步骤
      processSteps: [
        "裁剪", "制版", "绣花", "剪线头", "补片", "修片", 
        "拼片", "合里面", "做条", "包边", "做唛", "修边", 
        "扣眼", "包扣", "钉扣", "打缎带", "印字", "定面", 
        "定里", "整形", "检验", "修边", "发货"
      ],
      
      // 订单数据
      formData: {
        id: '1',
        orderNumber: 'WL12665-250604-39245',
        orderDate: '2025-05-23',
        typeOfOrder: 'Kippot',
        itemNumber: 'STN-223',
        quantity: 200,
        wholesalersRefNo: 'REF12345',
        estimatedShippingDate: '2025-06-30',
        eventDate: '2025-07-15',
        fullName: 'Dmitrij Belkin',
        size: '19 cm',
        telephone: '004915156024584',
        panel: 4,
        email: 'info@levinson-stiftung.de',
        shippingAddress: 'Am Neuen Palais 10, 14469 Potsdam, Germany',
        buttonColor: '#FF0000',
        stitchingColor: '#000000',
        rimColor: '#808080',
        liningColor: '#FFFFFF',
        fringeColor: '#000000',
        stringColor: '#000000',
        clipsColor: '#C0C0C0',
        sellersTag: 'DavidKippot',
        outsideEmbroidery: 'NATHAN PETER LEVINSON STIFTUNG',
        insidePrintings: 'Logo and name',
        embOrPr: 'Embroidery',
        embroidery: 'Logo on front',
        printings: 'Name on back',
        seeRefColor: 'Refer to sample',
        model: 'Standard',
        seeAllInside: 'Check Sheet2',
        insideType: 'Label',
        printingsOnLabelColor: '#000000',
        font: 'Arial',
        specialRequest: 'Send photo for approval before batch production',
        orderStatus: 'processing',
        shippingDate: '2025-06-28',
        courier: 'DHL',
        trackingNumber: '1234567890',
        orderRemarks: 'High priority order, ensure timely delivery',
        itemPhoto: ''
      },
      
      // 颜色字段配置
      colorFields: [
        { label: '按钮颜色', prop: 'buttonColor' },
        { label: '缝线颜色', prop: 'stitchingColor' },
        { label: '边缘颜色', prop: 'rimColor' },
        { label: '内衬颜色', prop: 'liningColor' },
        { label: '流苏颜色', prop: 'fringeColor' },
        { label: '绳线颜色', prop: 'stringColor' },
        { label: '夹子颜色', prop: 'clipsColor' }
      ]
    }
  }
}
</script>

<style scoped lang="scss">
.dashboard-container {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: 100vh;
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
}

.process-header {
  text-align: center;
  margin-bottom: 20px;
  
  h2 {
    color: #303133;
    font-size: 24px;
    margin-bottom: 8px;
  }
  
  p {
    color: #606266;
    font-size: 16px;
  }
}

.steps {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-bottom: 30px;
}

.order-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  padding: 30px;
}

.section-title {
  color: #409eff;
  font-size: 18px;
  padding-bottom: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid #ebeef5;
  position: relative;
  
  &::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 60px;
    height: 2px;
    background-color: #409eff;
  }
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 15px;
}

.form-group {
  &.full-width {
    grid-column: 1 / -1;
  }
}

.form-input {
  width: 100%;
}

.color-item {
  display: flex;
  align-items: center;
  
  ::v-deep .el-form-item__content {
    display: flex;
    align-items: center;
    
    .el-color-picker {
      margin-right: 10px;
    }
  }
}

.color-value {
  font-size: 14px;
  color: #606266;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.image-upload-container {
  width: 120px;
  height: 120px;
  border: 1px dashed #dcdfe6;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background-color: #f5f7fa;
  
  .item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
  }
  
  .image-placeholder {
    text-align: center;
    color: #c0c4cc;
    
    i {
      font-size: 32px;
      margin-bottom: 8px;
    }
    
    p {
      font-size: 12px;
      margin: 0;
    }
  }
}

.action-buttons {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #ebeef5;
  display: flex;
  justify-content: flex-end;
  
  .btn-save {
    background-color: #409eff;
    border-color: #409eff;
    padding: 10px 25px;
  }
  
  .btn-cancel {
    background-color: #fff;
    color: #606266;
    border: 1px solid #dcdfe6;
    padding: 10px 25px;
    margin-left: 15px;
    
    &:hover {
      background-color: #f5f7fa;
    }
  }
}

@media (max-width: 992px) {
  .form-grid, .color-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
}
</style>